package com.lingx.model.impl.validator;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.lingx.model.IContext;
import com.lingx.model.IPerformer;
import com.lingx.model.impl.AbstractValidator;
import com.lingx.model.impl.DefaultField;

/** 
 * @author www.lingx.com
 * @version 创建时间：2015年10月7日 下午9:41:28 
 * 类说明 
 */@Component
public class TreeFidValidator  extends AbstractValidator {
	
	public static final String sql="select id from %s where fid=?";

	private static final long serialVersionUID = -2378034202921820146L;

	public TreeFidValidator() {
		super("TreeFidValidator", "树形结构验证");
		this.setComment("不需要额外参数");
	}

	@Resource
	private JdbcTemplate jdbcTemplate;
	@Override
	public boolean valid(Object value,String param,Map<String,Object> params,DefaultField field,IContext context)throws Exception {
		if(!"fid".equals(field.getCode().toLowerCase()))return true;
		//if(Utils.isNull(context.getRequest().getParameter("id"))) return true;
		if(value==null)return false;
		boolean b=false;
		Set<String> sets=new HashSet<String>();
		//tree(context.getRequest().getParameter("id"),context.getEntity().getTableName(),sets);
		//b=!sets.contains(value.toString());
		sets.clear();
		return b;
	}

	
}
